//
// Created by wkm on 2023-12-13.
//

#ifndef MYSYSTEMCLEARNING_GENERIC_ALU_H
#define MYSYSTEMCLEARNING_GENERIC_ALU_H

#include "systemc.h"

const int DATA_SIZE = 8;
const int NUM_OPS = 4;

enum op_type {
    add_op, sub_op, mul_op, div_op
};

SC_MODULE(generic_alu) {
    sc_in<sc_uint<DATA_SIZE>> a, b;
    sc_in<op_type> select;
    // 输出必须为逻辑向量类型
    // 因为它可以为“X”值
    sc_out<sc_lv<DATA_SIZE>> z;

    // 成员变量控制算术逻辑单元的功能
    sc_uint<NUM_OPS> enable_mask;

    void prc_alu();

    SC_CTOR(generic_alu) {
        SC_METHOD(prc_alu);
        sensitive << a << b;
        enable_mask = 0xF;
    }
};

#endif //MYSYSTEMCLEARNING_GENERIC_ALU_H
